Creating state managers

Use states to define the look and behavior of your Kanzi application in different states. For example, you can use states to:

Properties set in states override the default, inherited, and local property values.

Adding a state manager to your project

Use state managers in your Kanzi project to control the states of nodes.
For example, a state manager can define the states of a toggle button. The state manager sets how the toggle button looks when it is toggled on and off.

To create toggle button states:

  1. In the Project select the Toggle Button 2D node and in the State Tools click Create State Manager.
    You can find the State Tools window below the Preview window.
    Kanzi Studio creates a new state manager and assigns it to the Toggle Button 2D node.
  2. In the State Tools click Create State twice to create two states, double-click the name of each state, and rename the states.
    For example, name one state On and the other Off.
    The On state defines the state of your application when the toggle button is switched on, the Off state when the toggle button is switched off.
    To delete a state, right-click the state and select Delete.
  3. Use the State Tools to define in which position the indicator of a toggle button is in the on and off states:
    1. Position the toggle button indicator and in the State Tools click below the On state to save the current position of the indicator to that state.
      For example, in the Preview use the Node tool to position the indicator.

    2. Repeat the previous step for the Off state and in the State Tools save the current position of the toggle button indicator to that state.

Using a controller property

In a state manager the value of the property you select as the Controller Property defines the conditions when each state in a state group is active. You can also use a custom property type as the controller property of a state group.
Each state group in a state manager can use a different controller property.

To set a controller property:

  1. In the State Tools click the <No Controller Property> dropdown menu and select the Button > Toggle State property.
    When you set the Toggle State as the controller property for the state manager that controls the states of a toggle button, the state manager transitions to a state based on the value of that property.
    To create a custom controller property, click the <No Controller Property> dropdown menu and select + Create Property Type.

  2. In the State Tools set the value of the controller property for each state.


  3. In the State Tools click Edit State Manager to deactivate the State Tools.

When you click the toggle button in the Preview you toggle between the On and Off states you defined in the state manager that you created in the Toggle Button 2D node.

Using state groups

State groups contain states, define controller properties, and transitions between states in a state group. Use state groups to smoothly control the states and transitions in your application. For example, a state manager for a button can contain three state groups: button pressed, button released, and hover over button. In each state group you create states, which use state objects to define how the button behaves in each state.

To create state groups:

  1. In the State Tools click + Create State Group to create a state group and enter the name for the state group you created.
  2. In the State Tools bring the mouse pointer over a state group to set the properties that this state group records. Set different state groups to record the changes in different property values. Use the All to select or deselect all properties.
    To duplicate or remove a state group, hover over the state group and select Duplicate or Remove.

Using state managers in the API

For details, see the StateManager class in the API reference.

See also

State manager

Using state transitions

Using the Button nodes

Property types

Creating property types